<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>客户端渲染</title>
</head>

<body>
  <div id="root">

  </div>

  <script>
    const xhr = new XMLHttpRequest;
    xhr.open('GET', '/user', true);
    xhr.send();
    xhr.onreadystatechange = () => {
      if (xhr.readyState == 4 && xhr.status == 200) {
        let json = JSON.parse(xhr.responseText)
        let html = `
          <ul>
            <li>${json.id}</li>
            <li>${json.name}</li>
          </ul>
        `
        document.querySelector('#root').innerHTML = html;
      }
    }

  </script>

</body>

</html>